package com.example.demo.system.controller;

import com.example.demo.system.entity.Role;
import com.example.demo.system.service.RoleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.Valid;
/**
* @author 许久龙
* @since 2022-02-19
*/
@RestController
@RequestMapping("api")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("/role")
    @ApiOperation("Role查询单个")
    public ResultVO getRole(@RequestBody Role role){
     ResultVO resultVO = roleService.getRole(Role role);
     return  resultVO;
   }

    @GetMapping("/role")
    @ApiOperation("Role查询全部")
    public ResultVO getAllRole(){
        ResultVO resultVO = roleService.getAllRole();
        return  resultVO;
    }

    @PostMapping("/role")
    @ApiOperation("Role新增")
    public ResultVO add(@Valid @RequestBody Role role) {
        ResultVO resultVO = roleService.add(Role role);
        return  resultVO;
    }

    @PutMapping("/role")
    @ApiOperation("Role修改")
    public ResultVO update(@Valid @RequestBody Role role) {
        ResultVO resultVO = roleService.update(Role role);
        returnresultVO;
    }


    @DeleteMapping(value = "/role/{ids}")
    @ApiOperation("Role删除(单个条目)")
    public ResultVO remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        ResultVO resultVO = roleService.remove(String ids);
        return resultVO;
    }
}
